﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class tin : System.Web.UI.Page
{
    string id;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)
        {
            id = Request.QueryString["id"].ToString();
            Tin tin = new Tin();
            ObjTin objTin = new ObjTin();

            //lay chi tiet tin
            objTin = tin.getTinByTinId(id);
            lb_ten_tin.Text = objTin.Tieu_de;
            Page.Title = objTin.Tieu_de;

            //lay danh dach tin con
            List<ObjTin> lstObjTin = tin.getTinByTinChaId(id);
            if (lstObjTin.Count == 0)
            {
                Response.Redirect("/tin/" + id +"/"+ Utils.GetTitle( lb_ten_tin.Text) + ".html");
            }
            else
            {
                CollectionPager2.DataSource = lstObjTin;
                CollectionPager2.BindToControl = datalist_tin;
                datalist_tin.DataSource = CollectionPager2.DataSourcePaged;
            }
        }
    }
}